<!doctype html>
<html>
<head>
    <meta charset="UTF-8" />
    <title>支付</title>
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/base.css" />
    <link rel="stylesheet" type="text/css" href="__PUBLIC__/Wx/css/detail.css" />
</head>
<body>
<div class="prodetail">
    <div class="address" >
        <div class="add" style="background:none ;">
            <a href="javascript:0;">
                <h3><span class="address_name">{$address.name}</span><span class="address_mobile">{$address.mobile}</span></h3>
                <p class="address_content">收货地址：{$address.address}</p>
            </a>
        </div>
    </div>

    <!--未填写地址-->
    <!--<div class="address">-->
    <!--<a href="javascript:0;"><span>添加收货人信息</span></a>-->
    <!--</div>-->
    <volist name="wholesale"  id="vo">
        <div class="prolist" style="border-bottom: 1px #f0f0f0 solid;">
            <volist name="vo['commodity']" id="sg">
                <div class="pro" wid="{$sg.id}" onclick="window.location.href='http://www.xiangtws.com/index.php/Wx/Wholesale/prodetail/id/{$sg.g_id}'">
                    <div class="pic"><img src="<?=isMorePic($sg['store_info']['h_imgs'])?>"/></div>
                    <div class="name">
                        <h2>{$sg.store_info.title} {$sg.store_info.u_num}<?=getunit($sg['store_info']['unit'])?></h2>
                        <p><b><img src="{$vo.g_u_id.avatar}"/></b><i>{$vo.g_u_id.nickname}</i><em>{$vo.g_u_id.farmers}</em></p>
                        <h3><del>原价：{$sg.store_info.price}</del><em>￥{$sg.price}</em><i>（{$sg.price_range.start}-{$sg.price_range.end}件）</i><b>X{$sg.num}</b></h3>
                    </div>
                </div>
            </volist>
        </div>
        <!--<div class="number-pf">购买数量<span class="num"><s class="reduce" onClick="ChangeNumber(-1)">-</s><input type="text" id="Number" value="1" class="Number"/><s class="Add" onClick="ChangeNumber(1)">+</s></span></div>-->
        <div class="total">共<b><?=count($vo['commodity'])?></b>件商品<span>合计：<i>￥{$vo.price_all}</i></span></div>
        <div class="ordermess" style="margin: 0px auto;">
            <p>创建时间：<?=date("Y-m-d H:i:s",$vo['commodity'][0]['addtime'])?></p>
            <p>订单编号：{$vo['commodity'][0]['order_sn']}</p>
        </div>
    </volist>
    <div class="sure">
        <p style="font-size:12px;">应付金额：<em style="font-size:12px;" class="price_all"></em><b>（3%服务费）</b></p>
        <input type="submit" value="支付" class="button" style="width:28%;"/>
    </div>
    <div class="expressfee">
        <div class="express">
            <h2>配送方式</h2>
            <p><span>快递￥10</span></p>
            <h3>关闭</h3>
        </div>
    </div>
    <div class="money02" style="margin-top: 10px;margin-bottom: 0px;">
        <!--<h1>乡土味士</h1>-->
        <!--<h2>￥19.90</h2>-->
        <div class="time03">
            <div class="time-item">支付时间剩余：<if condition="floor($deadline/60/60/24) neq 0"><span id="day_show">0</span>天</if><strong id="hour_show"><s id="h"></s>0</strong>时<strong id="minute_show"><s></s>00</strong>分<strong id="second_show"><s></s>00</strong>秒</div>
        </div>
    </div>
    <div class="payway">
        <ul>
            <if condition="$credit2 lt $pay_info['total_fee']">
                <li class="no"><span>卡额支付</span><em>（卡额不足，剩余<b>{$credit2}</b>元）</em><input type="radio" name="on" disabled="true"/></li>
                <else />
                <li id="code02"><span>卡额支付</span><em>（剩余<b>{$credit2}</b>元）</em><input type="radio" name="on" checked class="selected"/></li>
            </if>
            <li class="wxpay"><span style="background:url(__PUBLIC__/Wx/img/wechat02.png) no-repeat left center; background-size:23px 20px;">微信支付</span><input type="radio" name="on"/></li>
        </ul>
    </div>

    <!--<div class="button"><input type="button" value="确认支付"/></div>-->
    <div class="hint04">
        <div class="shadow">
            <div class="close"></div>
            <form action="" enctype="multipart/form-data" method="post" id="cart_forehead">
                <div class="succeed">
                    <h2>请输入卡额支付密码</h2>
                    <h3>乡土味士</h3>
                    <h4>￥{$pay_info['total_fee']}</h4>
                    <h5><input type="password" name="password" placeholder="点击输入卡额支付密码"/></h5>
                    <p><input type="button" value="取消" class="left"/><input type="button" value="确定" class="right"  /></p>
                </div>
            </form>
        </div>
    </div>
</div>
<script  src="__PUBLIC__/Wx/js/jquery-1.9.1.js" type="text/javascript"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var wid = new Array();
        $("div.pro").each(function(){
            wid.push($(this).attr('wid'));
        });//end each

        $.post("http://www.xiangtws.com/index.php/Wx/Wholesale/editshopping",{'op':'price','wid':wid},function (price) {
            // console.log(price);
            var text = "￥"+price.all;

            if (price.all != 0){
                text += '+￥'+price.charge;
            }//end if

            $("em.price_all").text(text);
        });//end post
        // $(".ok b").text(d.num);
    });

    $('.deliver').click(function(){
        $('.expressfee').css('display','block')
    });
    $('.expressfee h3').click(function(){
        $('.expressfee').css('display','none')
    });
</script>
<script type="text/javascript">
    $('.payway ul li input').click(function(){
        $(this).addClass("selected").parents('li').siblings('li').children('input').removeClass()
    });
    $(".button").click(function(){
        if($('#code02 input').hasClass("selected")){
            $('.hint04').css('display','block')
        }else{
            $('.hint04').css('display','none')
        }//end if
        if($(".wxpay input").hasClass('selected')){
            //微信支付
            window.location.href="http://www.xiangtws.com/Api/Salepay/wholesale_pay?id="+{$pay_info['id']}
            // window.location.href = 'http://www.xiangtws.com/Api/Weixinpay/pay?order_id='+order_id;
        }//end if
    });

    //卡额支付
    $(".right").click(function () {
        var formData = new FormData($('#cart_forehead')[0]);
        formData.append("id","{$pay_info['id']}");//增加表id
        formData.append("table","wholesale_pay_log");
        formData.append("type","批发");

        $.ajax({
            url: "http://www.xiangtws.com/index.php/Api/Salepay/cardPay",
            method: 'POST',
            data: formData,
            contentType: false, // 注意这里应设为false
            processData: false,
            cache: false,
            success: function(d) {
                // console.log(d);
                if(d.state>0){
                    // 支付失败
                    $('.hint04').css('display','none');
                    // window.location.reload();
                    alert(d.val);
                }else{
                    //支付成功
                    window.location.href=d.url;
                }//end if
            },
            error: function (d) {
                // console.log(d)
            }
        });//end ajax

    });//end fun

    $('.hint04 .close').click(function(){
        $('.hint04').css('display','none')
    });
    $('.hint04 .left').click(function(){
        $('.hint04').css('display','none')
    });
</script>
<script type="text/javascript">
    var intDiff = parseInt("{$deadline}");//倒计时总秒数量

    function timer(intDiff){
        window.setInterval(function(){
            var day=0,
                hour=00,
                minute=0,
                second=0;//时间默认值
            if(intDiff > 0){
                day = Math.floor(intDiff / (60 * 60 * 24));
                hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
                minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
                second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
            }
            if (minute <= 9) minute = '0' + minute;
            if (second <= 9) second = '0' + second;
            $('#day_show').html(day+"");
            $('#hour_show').html('<s id="h"></s>'+hour+'');
            $('#minute_show').html('<s></s>'+minute+'');
            $('#second_show').html('<s></s>'+second+'');
            intDiff--;

            //检测截止支付
            if(intDiff == 0){

            }//end if
        }, 1000);
    }
    $(function(){
        timer(intDiff);
    });
</script>
</body>
</html>